#include<bits/stdc++.h>
using namespace std;

int T, n, m, len, val, p[100010], ans, ans2, maa = -2000, mia = 2000;

inline int b_s(int x);
inline void solve();
inline void read(int& n);
inline void dfs(int p, int sum);

struct Info{
    int d, v, a;
    inline bool check(int q = -1){
        maa = max(maa, a);
        mia = min(mia, a);
        int add;
        if(q != -1)
            add = q;
        else if(a >= 0)
            add = p[m];
        else
            add = b_s(d);
        int s = add - d;

        int det = v * v + 2 * a * s - val * val;
        if(s < 0)
            return 0;
        if(det <= 0)
            return 0;
        return 1;
    }
} a[100010];

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    read(T);
    for(; T--;)
        solve();
    return 0;
}

inline int b_s(int x){
    int L = 0, R = m + 1;
    for(;L + 1 < R;){
        int M = (L + R) / 2;
        if(p[M] < x)
            L = M;
        else
            R = M;
    }
    return p[R];
}

bool c[21];

inline void solve(){
    read(n), read(m), read(len), read(val);
    for(int i = 1; i <= n; i++)
        read(a[i].d), read(a[i].v), read(a[i].a);
    for(int i = 1; i <= m; i++)
        read(p[i]);
    sort(p + 1, p + m + 1);
    ans = ans2 = 0;
    for(int i = 1; i <= n; i++)
        ans += a[i].check();
    if(n <= 20 && m <= 20){
        memset(c, 0, sizeof(c));
        dfs(1, 0);
        printf("%d %d\n", ans, ans2);
        return;
    }
    if(mia >= 0){
        if(!ans)
            m++;
        printf("%d %d\n", ans, m - 1);
        return;
    }
    printf("%d %d\n", ans, ans2);
}

inline void read(int& n){
    n = 0;
    int f = 1;
    char c;
    for(c = getchar(); c > '9' || c < '0'; c = getchar())
        if(c == '-')
            f = -1;
    for(; c >= '0' && c <= '9'; c = getchar())
        n = n * 10 + c - '0';
    n *= f;
}

inline void dfs(int q, int sum){
    if(q == m + 1){
        int s = 0;
        for(int i = 1; i <= n; i++)
            s += c[i];
        if(s == ans)
            ans2 = max(ans2, sum);
        return;
    }
    int w[21], k = 0;
    dfs(q + 1, sum + 1);
    if(ans2 > 0)
        return;
    for(int i = 1; i <= n; i++)
        if(a[i].check(p[q])){
            if(!c[i])
                w[++k] = i;
            c[i] = 1;
        }
    dfs(q + 1, sum);
    for(int i = 1; i <= k; i++)
        c[w[i]] = 0;
}
